#include <bits/stdc++.h>
#define int long long
using namespace std;
int n,a[500005],b[500005],k;
bool check(int x)
{
	if(x<a[1]*2) return 0;
	int cnt=1,nw=a[1];
	for(int i=2;i<=n;i++)
	{
		if(nw+a[i]<=x) nw=a[i],++cnt;
		else if(nw>a[i]) nw=a[i]; 
	}
	return cnt>=k;
}
signed main()
{
    freopen("sub.in","r",stdin);
    freopen("sub.out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> k;
	pair<int,int> mn={2e9,2e9};
	for(int i=1;i<=n;i++)
	{
		cin >> a[i];
		mn=min(mn,{a[i],i});
	}
	int nw=mn.second;
	int C=0;
	do
	{
		b[++C]=a[nw];
		++nw;
		if(nw==n+1) nw=1;
	}while(nw!=mn.second);
	swap(a,b);
//	for(int i=1;i<=n;i++) cout << a[i] << " ";
//	cout << "\n";
	int l=0,r=2e9,ans=0;
	while(l<=r)
	{
		int mid=(l+r)/2;
		if(check(mid)) ans=mid,r=mid-1;
		else l=mid+1;
	}
	cout << ans;
	return 0;
}
